package com.huanletao.spring.multdatasource.service;


import com.huanletao.spring.multdatasource.DataSource;
import com.huanletao.spring.multdatasource.dao.StudentRepository;
import com.huanletao.spring.multdatasource.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class StudentService {

    @Autowired
    StudentRepository studentRepository;


    @Transactional(rollbackFor = Exception.class,transactionManager = "transactionManagerSlave")
    @DataSource("slave")
    public void insertStudent(){
        Student student = new Student();
        student.setPassword("123344");
        student.setUsername("admin");
        Student save = studentRepository.save(student);
//        jdbcTemplate.

        int i = 1/0;
    }
}
